#include <stdio.h>
#include <stdlib.h>

typedef struct Node{
	int data;
	struct Node *next;
}Node ,*PNode;

void push (PNode *p , int x)
{
	PNode head = (*p);
	PNode newnode = (PNode)malloc(sizeof(Node));
	newnode->data = x;
	newnode->next = 0;

	if (head == NULL)
	{
		(*p) = newnode;
	}
	else
	{
		newnode->next = head;
		(*p) = newnode;
	}

}//头插法

void pop (PNode *p)
{
	PNode head = (*p);
	(*p) = (*p)->next;
	free(head);
}

int get_top (PNode *p)
{
	PNode head = (*p);
	return head->data;
}

int Is_Empty (PNode *p)
{
	return !(*p);
}

void Print (PNode *p)
{
	PNode head = (*p);
	for (head ; head != NULL ; head = head->next)
	{
		printf ("%d " , head->data);
	}
}

int pop_1 (PNode *p)
{
	PNode head = (*p);
	(*p) = (*p)->next;
	int tem = head->data;
	free(head);
	return tem;
}

int main ()
{
	PNode linklist = NULL;

	push (&linklist , 3);
	push (&linklist , 5);
	push (&linklist , 4);
	push (&linklist , 3);
	pop (&linklist);
	Print (&linklist);
	printf ("\n%d" , get_top(&linklist));
	printf ("\n%d" , Is_Empty(&linklist));

	return 0;
}


